<?

$League_Parent = (isset($LeagueDirPurview['LParentMenu'])&&is_array($LeagueDirPurview['LParentMenu']))?$LeagueDirPurview['LParentMenu']:array();
$League_LChildMenu = (isset($LeagueDirPurview['LChildMenu'])&&is_array($LeagueDirPurview['LChildMenu']))?$LeagueDirPurview['LChildMenu']:array();

if($LeagueDirPurview==-1)$ischecked= ' checked ';
echo "<dl ID=\"permissionMenu\">";
$i=1;
$j=1;
foreach($LeagueManagerDirArray as $key=>$value){
	
	//if($LeagueDirPurview!=-1&&!in_array($key,$League_Parent)) continue;
	echo "<dt><span>".$value['LParentMenu']."</span><input type='checkbox' name='selectAll' id='selectAll".$i."' /><label class='normal' for='selectAll".$i."'>ȫѡ</label>"."<input class='hide' type=\"checkbox\" name=\"LParentMenu[]\" value=\"{$key}\"".(in_array($key,$League_Parent)? ' checked ' :$ischecked)."></dt><dd><ul>";
	if(!isset($value['LChildMenu'])||!is_array($value['LChildMenu']))continue;
	foreach($value['LChildMenu'] as $key2=>$value2){
		
		//if($LeagueDirPurview!=-1&&!in_array($key2,$League_LChildMenu))continue;
		
		echo "<li><label for='option".$j."'>".$value2['Name']."</label>"."<input class='checkbox' type=\"checkbox\" id='option".$j."' name=\"LChildMenu[]\" value=\"{$key2}\"".(in_array($key2,$League_LChildMenu)?' checked ':$ischecked).">";	
		echo "</li>";
		$j++;
	}
		
	echo "</ul></dd>";
    $i++;
}
echo "</dl>";
?>
<script language="javascript">
(function(){
	var selectalls = document.roleManagement.selectAll;
	for(var i=0;i<selectalls.length;i+=1){
		selectalls[i].onclick = function(){
			var b = this.parentNode;
			var next = b.nextSibling;
			var self = this;
			while(!/dd/i.test(next.tagName)){next=next.nextSibling;};
			var checkboxs=next.getElementsByTagName('input');
			for(var j=0;j<checkboxs.length;j+=1){
				var checkbox = checkboxs[j];
				if(checkbox.type!=='checkbox'){continue;}
				checkbox.checked = self.checked?1:0;
				checkbox.onclick = function(){
					self.checked = 0;
				}
			}
		}
	}
})()
</script>
</script>